home *** CD-ROM | disk | FTP | other *** search
- Path: crc-news.doc.ca!usenet
- From: Slobodan Celenkovic <slobodan@cs.unh.edu>
- Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
- Subject: Re: C++ with Zapp vs. Delphi
- Date: 18 Jan 1996 21:06:57 GMT
- Organization: The Communications Research Centre
- Message-ID: <4dmcph$6sv@crc-news.doc.ca>
- References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <WaE/w0JfFiKC089yn@oslonett.no> <4dkp2c$3d7m@tigger.cc.uic.edu>
- NNTP-Posting-Host: celenkovic.bob.fob003.ic.gc.ca
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
- olczyk@sunphy1 (Jung Oh) wrote:
- >Rune Moberg (mobergru@oslonett.no) wrote:
- >: void (ah, a function returning nothing - aka procedure in Pascal)
- >: sort (the function name)
- >: void* base (uhm... An undefined pointer?)
- >pointer to undefined type -- like Pascal POINTER
-
- yes, C/C++ "void*" is the same as Pascal "pointer" => a generic pointer
-
- >: unsigned int sz (definatively an unsigned integer)
- >: CFT cmp (right, a variable of type CFT declared above)
- >
- >: typedef int (*CFT) (void*,void*);
- >: is what got me. What is this? Could it be a typedeclaring a function
- >: returning an int, with two undefined arguments (pointers)? It would
- >: probably deserve a comment (or three), or one could write it in
- Pascal.
-
- Pascal version:
-
- type CFT = function(p1 : pointer; p2 : pointer) : integer ;
-
- C/C++ allows you to skip the param names (p1 & p2) in the prototype.
-
- So both declare the function TYPE called CFT with the defined prototype
- (2 generic pointers and returns an integer). Idea is that the function
- gets pointers to 2 objects/variables which are supposed to be compared.
- Then it is supposed to returns a comparison code (smaller, larger,
- equal).
-
- >However the whole arguement begs the question. When a method accepts a TObject
- >and typecasts it to other types so that it can send a method to it, the
- >method's class can never be closed to change since there may be other
- >classes generated later which must be typecast also.
- >---------------------------
- >Thaddeus L. Olczyk
-
- Absolutely correct. That is exactly why use polymorphism instead of
- typecasting. Typecasting hard-codes types, hence hindering future
- additions of new types. Polymorhism doesn't.
-
-